
local indata LAD\Data
local infile LAD\Data_Cleaning

use "`indata'\LAD_Crowdout.dta", clear

do "`infile'\LAD_Commands_filtering.do"

*Focus on savers within the relevant bandwidth
keep if empinc>=-6000 & empinc<6000

*Non-Unionized RPP Non-Members do not satisfy the Test of Running Variable and are excluded
keep if dues>0
*Focus on RPP members with non-zero observed savings
keep if penadj>0 & (rspcont>0|rspwd>0|invinc>0|capgain>0)
keep if rspcont<rspdlc & (penadjl+rspcont)<contlimit

*Note that I use a different measure of other income here, which subtracts investment income and capital gains
*This is done because these variables are sometimes included in the dependent variable in these regressions
local covars age agesq female married province_* selfempinc_flag eiinc_flag othinc2 disab medexp

*-------------------------------------------------
*1) Allowing RRSP net contributions to be negative
*-------------------------------------------------

qui reg penadj empinc empinc_kink `covars' if (rspcont>0 | rspwd>0)
est store rppreg
qui reg rspnetcont empinc empinc_kink `covars' if (rspcont>0 | rspwd>0)
est store savreg
suest savreg rppreg, cl(id)
nlcom (ratio: [savreg_mean]_b[empinc_kink]/[rppreg_mean]_b[empinc_kink]), post
test _b[ratio]=-1

*-------------------------------
*2) Income from investments only
*-------------------------------

qui reg penadj empinc empinc_kink `covars' if invinc!=0
est store rppreg
qui reg invinc empinc empinc_kink `covars' if invinc!=0
est store savreg
suest savreg rppreg, cl(id)
nlcom (ratio: [savreg_mean]_b[empinc_kink]/[rppreg_mean]_b[empinc_kink]), post
test _b[ratio]=-1

exit
